using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Core;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Xml;


namespace Yuanlin.Business
{
    public class DefaultSectionManager
    {
        private const string cacheKey = "DefaultSection";
        private static DefaultSections defaultSections = null;
        static DefaultSectionManager()
        {
            if (CacheManager.Get(cacheKey) == null)
            {
                string defaultSectionsFile = Globals.MapPath(ConfigurationManager.AppSettings["DefaultSections"]);
                XmlDocument doc = new XmlDocument();
                doc.Load(defaultSectionsFile);
                if (doc.DocumentElement != null)
                {
                    defaultSections = new DefaultSections(doc.DocumentElement);
                }
            }
            else
            {
                defaultSections = CacheManager.Get(cacheKey) as DefaultSections;
            }
        }

        public static DefaultSection GetDefaultSection(string name)
        {
            if (defaultSections != null)
            {
                return defaultSections.DefaultSection[name] as DefaultSection;
            }
            return null;
        }
    }
}
